import App from './App'

// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
// #endif
// main.js
// import {
// 	createSSRApp
// } from 'vue'
// export function createApp() {
// 	const app = createSSRApp(App)
// 	return {
// 		app
// 	}
// }
//创建类
const ran = {
	location: 'https://www.shandianzuche.com/',
	imgpath: 'https://www.shandianzuche.com/',
	version: '1.0.0',
	timetrans: function(date) {
		var date = new Date(date);
		date.setTime(date);
		var Y = date.getFullYear() + '-';
		var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
		var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
		var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
		var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
		var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
		return Y + M + D + h + m + s;
	},
	addflag: function(list, t) {
		list.forEach((item, index) => {
			t.$set(item, "flag", false)
		})
	},
	request: function(location, data) {
		return new Promise((resolve, reject) => {
			uni.request({
				url: this.location + location,
				data: data,
				method: 'POST',
				dataType: 'json',
				success: (res) => {
					// console.log(res);
					var data;
					// console.log(typeof(res.data))
					if (typeof(res.data) == 'string') {
						// if(res.data.code == null){
						data = JSON.parse(res.data);
					} else {
						data = res.data;
					}
					// if(data.code == 0){
					// uni.showToast({
					// 	title: data.msg,
					// 	icon: 'none',
					// 	duration: 2000
					// });
					// }else{
					resolve(data)
					// }
				},
				fail: (err) => {
					uni.showToast({
						title: '网络出错',
						icon: 'error',
						duration: 2000
					});
				}
			});
		})
	}
}
Vue.prototype.ran = ran; //推到全局